package com.liaoban.app.ui.base;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.widget.TextView;

import com.liaoban.app.R;

import butterknife.BindView;

/**
 * Created by ChenYuYun on 2018/4/25.
 * 含有标题的activity
 */
public abstract class BaseToolbarActivity extends BaseActivity {
    @BindView(R.id.toolbar)
    public Toolbar toolbar;

    @BindView(R.id.tv_title)
    TextView tvTitle;

    /*@Override
    public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        initTitle();
    }*/

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initTitle();
    }

    private void initTitle() {
        setSupportActionBar(toolbar);
        getSupportActionBar().setTitle("");
        tvTitle.setText(getNewTitle());
        toolbar.setNavigationOnClickListener(v -> this.finish());//后退键
    }

    /**
     * 获取标题名称
     *
     * @return
     */
    protected abstract String getNewTitle();

}
